<?php

require_once 'common/conn.php';

$usercode = $_GET['usercode'];
if (!isset($usercode)) {
    $usercode = $_POST['usercode'];
}

$result = array();

$db = new DBC();
$sql = "SELECT schoolid FROM t_device WHERE devicecode = '" . $usercode . "'";
$data = $db->fetchData($sql);
if (count($data) > 0) {
    if ($data[0]['schoolid'] > 0) {
        $result['errorNo'] = 0;
        $result['schoolid'] = $data[0]['schoolid'];
    } else {
        $result['errorNo'] = 1;
    }
} else {
    $result['errorNo'] = 1;
};
echo json_encode($result);
?>
